/*
 * @Descripttion: 角色接口
 * @version:
 * @Author: cxguo
 * @Date: 2019-08-02 15:03:05
 * @LastEditors: cxguo
 * @LastEditTime: 2020-11-06 21:30:40
 */
import qs from 'qs'
import axios from '@/apis/axios/index.js'
const baseUrl = '/user'

export function register(params) {
	return axios.request({
		url: `${baseUrl}/register`,
		method: 'post',
		headers: {
			Authorization: null
		},
		data: params
	})
}

export function switchTenant(params) {
	return axios.request({
		url: `${baseUrl}/switchTenant`,
		method: 'post',
		data: params
	})
}

export function addTenantAndLogin(params) {
	return axios.request({
		url: `${baseUrl}/addTenantAndLogin`,
		method: 'post',
		data: params
	})
}


export function sendVerifyCodeForRegister(params) {
	return axios.request({
		url: `${baseUrl}/sendVerifyCodeForRegister`,
		method: 'post',
		headers: {
			Authorization: null
		},
		data: params
	})
}

export function sendVerifyCodeForForgot(params) {
	return axios.request({
		url: `${baseUrl}/sendVerifyCodeForForgot`,
		method: 'post',
		headers: {
			Authorization: null
		},
		data: params
	})
}

export function updatePassWordByVerifyCode(params) {
	return axios.request({
		url: `${baseUrl}/updatePassWordByVerifyCode`,
		method: 'post',
		headers: {
			Authorization: null
		},
		data: params
	})
}

export function login(params) {
	return axios.request({
		url: `/auth/oauth/token?grant_type=password`,
		method: 'post',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
			Authorization: 'Basic YnVlcnl1bl9hcHBfc2NhbjpidWVyeXVuX2FwcF9zY2Fu'
		},
		data: qs.stringify(params)
	})
}

export function logout(params) {
	return axios.request({
		url: `${baseUrl}/logout`,
		method: 'post',
		data: params
	})
}

export function updateRoles(params) {
	return axios.request({
		url: `${baseUrl}/updateRoles`,
		method: 'post',
		data: params
	})
}

export function getUserInfo() {
	return axios.request({
		url: `${baseUrl}/getUserInfo`,
		method: 'post'
	})
}

export function validateToken(params) {
	return axios.request({
		url: `${baseUrl}/validateToken`,
		method: 'post',
		data: params
	})
}

export function isExistUsername(params) {
	return axios.request({
		url: `${baseUrl}/isExistUsername`,
		method: 'post',
		data: params
	})
}

export function isExistPhoneNo(params) {
	return axios.request({
		url: `${baseUrl}/isExistPhone`,
		method: 'post',
		data: params
	})
}
